Completed
Pull Request — master (#120)
by Maxence
03:22
created

links.linkGroup   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
nc 1
nop 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A 0 3 1
A 0 3 1
1
/*
2
 * Circles - Bring cloud-users closer together.
3
 *
4
 * This file is licensed under the Affero General Public License version 3 or
5
 * later. See the COPYING file.
6
 *
7
 * @author Maxence Lange <[email protected]>
8
 * @copyright 2017
9
 * @license GNU AGPL version 3 or any later version
10
 *
11
 * This program is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License as
13
 * published by the Free Software Foundation, either version 3 of the
14
 * License, or (at your option) any later version.
15
 *
16
 * This program is distributed in the hope that it will be useful,
17
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 * GNU Affero General Public License for more details.
20
 *
21
 * You should have received a copy of the GNU Affero General Public License
22
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23
 *
24
 */
25
26
27
/** global: OC */
28
/** global: OCA */
29
30
var links = {
31
32
33
	linkCircle: function (circleId, remote, callback) {
34
		var result = {status: -1};
35
		$.ajax({
36
			method: 'POST',
37
			url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/link'),
38
			data: {
39
				remote: remote
40
			}
41
		}).done(function (res) {
42
			api.onCallback(callback, res);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
43
		}).fail(function () {
44
			api.onCallback(callback, result);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
45
		});
46
	},
47
48
49
	linkStatus: function (linkId, status, callback) {
50
		var result = {status: -1};
51
		$.ajax({
52
			method: 'POST',
53
			url: OC.generateUrl('/apps/circles/v1/link/' + linkId + '/status'),
54
			data: {
55
				status: status
56
			}
57
		}).done(function (res) {
58
			api.onCallback(callback, res);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
59
		}).fail(function () {
60
			api.onCallback(callback, result);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
61
		});
62
	},
63
64
65
	linkGroup: function (circleId, groupId, callback) {
66
		var result = {status: -1};
67
		$.ajax({
68
			method: 'PUT',
69
			url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/groups'),
70
			data: {
71
				name: groupId
72
			}
73
		}).done(function (res) {
74
			api.onCallback(callback, res);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
75
		}).fail(function () {
76
			api.onCallback(callback, result);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
77
		});
78
	},
79
80
81
	unlinkGroup: function (circleId, groupId, callback) {
82
		var result = {status: -1};
83
		$.ajax({
84
			method: 'DELETE',
85
			url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/groups'),
86
			data: {
87
				group: groupId
88
			}
89
		}).done(function (res) {
90
			api.onCallback(callback, res);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
91
		}).fail(function () {
92
			api.onCallback(callback, result);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
93
		});
94
	},
95
96
97
	levelGroup: function (circleId, group, level, callback) {
98
		var result = {status: -1};
99
		$.ajax({
100
			method: 'POST',
101
			url: OC.generateUrl('/apps/circles/v1/circles/' + circleId + '/group/level'),
102
			data: {
103
				group: group,
104
				level: level
105
			}
106
		}).done(function (res) {
107
			api.onCallback(callback, res);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
108
		}).fail(function () {
109
			api.onCallback(callback, result);
0 ignored issues
show
Bug introduced by
The variable api seems to be never declared. If this is a global, consider adding a /** global: api */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
110
		});
111
	}
112
113
};
114